home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MarkToken.h
-
- Contains: A token that contains a set of other tokens
-
- Written by: Andy Nicholas, Greg Anderson, Tom Conrad, Chris Bingham, Georgiann Puckett, John Thompson-Rohrlich
-
- Copyright: © 1994-1995 by Apple Computer, Inc., all rights reserved.
-
- <5> 6/6/95 ga
-
- */
-
- #ifndef MarkToken_h
- #define MarkToken_h
-
- //
- // ProxyToken.h is needed because
- // TProxyToken is the base class of TMarkToken
- //
- #include "ProxyToken.h"
-
- //
- // TAbstractIterator is the base class of TMarkIterator
- //
- #include "AbstractIterator.h"
-
- class TScriptableObjectList;
-
- #define cMarkToken 'mark'
-
- //
- // Needed for a callback in MoreAEM
- //
- TAbstractScriptableObject* MarkTokenMergeProc(TAbstractScriptableObject* baseToken, TAbstractScriptableObject* mergeToken);
-
- //========================================================================================
- //
- // CLASS TMarkToken
- //
- //========================================================================================
-
- class TMarkToken : public TProxyToken
- {
- public:
- DeclareSmallClassData(TMarkToken, TProxyToken);
-
- TMarkToken(TypeOfMarkToken markType) : fMarkList(nil), fIsUnionMark(markType) {};
- TMarkToken(TScriptableObjectList* list, TypeOfMarkToken markType) : fMarkList(list), fIsUnionMark(markType) {};
- virtual ~TMarkToken();
-
- virtual void CloneOwnedObjects();
-
- void IMarkToken();
- void SetUnionMark(TypeOfMarkToken isUnionMark) { fIsUnionMark = isUnionMark; }
- Boolean IsUnionMark() { return fIsUnionMark == kSingleItemOrUnion; }
-
- Boolean DerivedFromOSLClass(TTransaction* t, DescType objectClass);
-
- virtual TAbstractObjectIterator* DirectObjectIterator(TTransaction*);
- virtual TAbstractObjectIterator* ElementIterator(TTransaction*);
-
- virtual TAbstractScriptableObject* AdoptToken(TAbstractScriptableObject* token, TypeOfMarkToken);
- virtual void AddThisToMarkToken(TAbstractScriptableObject*& markToken, TypeOfMarkToken);
-
- virtual void AdjustMarks(long newStart, long newStop);
-
- protected:
-
- //
- // fMarkList is a list of all of the tokens designated by the mark token
- //
- TScriptableObjectList* fMarkList;
-
- //
- // fIsUnionMark is true if this mark token was created in order to
- // silently union together multiple hits to a request that is usually
- // matched by a single token (e.g. AccessByName, as in 'folder "Bad Idea"
- // of desktop', when there are two folders named "Bad Idea" on the desktop).
- //
- // Tokens unioned together in this manner will behave as a single
- // container; for example, 'count folder "Bad Idea" of desktop each item' will
- // return the sum of the number of items inside each folder named
- // "Bad idea" on the desktop. This is different than the behavior of
- // non-union mark tokens; for example, 'count every folder of desktop
- // whose name is "Bad Idea" each item' will return the number of
- // folders named "Bad Idea" on the desktop, because 'whose' clauses do
- // not generate union mark tokens.
- //
- // The only variation on behavior is in CaclulateCount and AccessByIndex.
- // I was tempted to make a class TUnionMarkToken : public TMarkToken, but
- // I was unsure if I might need to dynamicly transmogrify a non-union mark
- // into a union mark.
- //
- TypeOfMarkToken fIsUnionMark;
- };
-
-
- class TScriptableObjectListIterator;
-
-
- //========================================================================================
- // Class TMarkTokenIterator
- //========================================================================================
- class TMarkTokenIterator : public TAbstractObjectIterator
- {
- private:
- TScriptableObjectListIterator* fListIter;
- TAbstractObjectIterator* fCurrentIter;
- Boolean fDirection;
-
- TScriptableObjectList* fMarkList;
- Boolean fIterateElements;
- Boolean fRequireExists;
- Boolean fDeleteListOnDestruction;
-
- public:
- TMarkTokenIterator(TScriptableObjectList* markList, Boolean iterateElements, Boolean requireExists, Boolean deleteListOnDestruction = false) :
- fListIter(nil),
- fCurrentIter(nil),
- fDirection(kForwardIteration),
- fMarkList(markList),
- fIterateElements(iterateElements),
- fRequireExists(requireExists),
- fDeleteListOnDestruction(deleteListOnDestruction) { this->Reset(kForwardIteration); }
-
- virtual ~TMarkTokenIterator();
-
- //
- // Interface to code to:
- //
- virtual void Reset(TTransaction* t, Boolean iterationDirection = kForwardIteration);
- virtual Boolean More(TTransaction*) const;
- virtual void Next(TTransaction*);
- virtual TAbstractScriptableObject* Current(TTransaction*);
-
- virtual void SearchDeep(TTransaction* t, TAbstractCollector* collector, DescType desiredClass, TAbstractSearchSpec* searchSpec);
-
- private:
- void SetupCurrentIterator(TTransaction* t);
- };
-
-
- #endif
-
-